var mongoose = require('mongoose'),
    Schema = mongoose.Schema;

var db = require('../index').db;

// getHistory: 获取个股历史数据
// 返回数据格式 - 日期 ，开盘价， 最高价， 收盘价， 最低价， 成交量， 价格变动 ，涨跌幅，5日均价，10日均价，20日均价，5日均量，10日均量，20日均量，换手率
// "code":"600848","ktype":"week","start":"2017-06-18","end":"2017-07-18"
// ["2017-06-23","21.000","25.930","23.340","20.940","1668063.75","2.540","12.21","19.832","19.233","20.099","506,352.26","338,420.24","324,747.29","41.75"]
var historySchema = new Schema({
    id: String, // 显式id，设置为 code + date
    ktype: String, // 日线 day, 周线 week
    code: String, // 股票代码
    date: String,
    open: String,
    highest: String,
    close: String,
    lowest: String,
    vol: String, // 成交量， volume
    priceChange: String,
    changeRate: Number,
    ma5: String, // 5日均价
    ma10: String, // 10日均价
    ma20: String, // 
    vo5: String,
    vo10: String,
    vo20: String,
    tor: String // turnover rate
}, {
    versionKey: false, // 不自动插入__v字段
    collection: 'history'
});

exports.historySchema = historySchema;